home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / asmsrc / rebelssource.lha / Sources / ZOOM.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1994-07-09  |  8.3 KB  |  330 lines

  1.  
  2. {* Hardcore Pascal Object Coding done by Zulu & Grey of Rebels *}
  3.  
  4. PROGRAM definition_der_objekte_und_organisation;
  5.  
  6.   USES graph,crt;
  7.  
  8.   TYPE punkt      = OBJECT
  9.                       x,
  10.                       y    : REAL;
  11.  
  12.                       CONSTRUCTOR init(xwert,ywert : REAL);
  13.                       procedure out(VAR xwert,ywert : REAL);
  14.                       procedure zeigen; virtual;
  15.                       procedure loeschen; virtual;
  16.                       procedure addition(dx,dy : REAL); virtual;
  17.                       procedure multiply(mx,my : REAL); virtual;
  18.                       procedure spiegelnY(cy : real); virtual;
  19.                       procedure spiegelnX(cx : real); virtual;
  20.                       procedure verschieben(dx,dy,sx1,sy1,cx1,cy1 : real); virtual;
  21.                       procedure skalieren(bx,by,vx,vy: real);virtual;
  22.                     END;
  23.  
  24.        linie      = OBJECT(punkt)
  25.                       x1,
  26.                       y1   : REAL;
  27.  
  28.                       CONSTRUCTOR init(xwert,ywert,x1wert,y1wert : REAL);
  29.                       procedure out(VAR xwert,ywert,x1wert,y1wert : REAL);
  30.                       procedure zeigen; virtual;
  31.                       procedure addition(dx,dy : REAL); virtual;
  32.                       procedure multiply(mx,my : REAL); virtual;
  33.  
  34.                       {Prozedur VERSCHIEBEN wurde geerbt!}
  35.                     END;
  36.  
  37.        kreis      = OBJECT(punkt)
  38.                       radius : REAL;
  39.  
  40.                       CONSTRUCTOR init(xwert,ywert,rad : REAL);
  41.                       procedure out(VAR xwert,ywert,rad : REAL);
  42.                       procedure zeigen; virtual;
  43.  
  44.                       {Prozeduren ADDITION und VERSCHIEBEN von "punkt" geerbt!}
  45.                     END;
  46.  
  47.        rechteck   = OBJECT(linie)
  48.                       procedure zeigen; virtual;
  49.  
  50.                       {Restprozeduren von "linie" geerbt!}
  51.                     END;
  52.  
  53. {------------------------------Objekt Punkt----------------------------------}
  54.  
  55.   CONSTRUCTOR punkt.init(xwert,ywert : REAL);
  56.  
  57.     BEGIN
  58.       x := xwert;
  59.       y := ywert;
  60.     END;
  61.  
  62.   PROCEDURE punkt.out(VAR xwert,ywert : REAL);
  63.  
  64.     BEGIN
  65.       xwert := x;
  66.       ywert := y;
  67.     END;
  68.  
  69.   PROCEDURE punkt.zeigen;
  70.  
  71.     BEGIN
  72.       putpixel(round(x),round(y),getcolor);
  73.                 {Pixel an der Stelle (x,y) mit akt.Zeichenfarbe}
  74.     END;
  75.  
  76.   PROCEDURE punkt.loeschen;
  77.  
  78.     VAR altfarbe : WORD;
  79.  
  80.     BEGIN
  81.       altfarbe := getcolor;
  82.       setcolor(getbkcolor);
  83.       zeigen;
  84.       setcolor(altfarbe);
  85.     END;
  86.  
  87.   PROCEDURE punkt.addition(dx,dy : REAL);
  88.  
  89.     BEGIN
  90.       x := x + dx;
  91.       y := y + dy;
  92.     END;
  93.  
  94.   PROCEDURE punkt.verschieben(dx,dy,sx1,sy1,cx1,cy1 : real);
  95.  
  96.     BEGIN
  97.  
  98.       addition(0,0);
  99.    {   spiegelnx(sx1,sy1,cx1,cy1); }
  100.       zeigen;
  101.     END;
  102.  
  103.   PROCEDURE punkt.multiply(mx,my : real);
  104.  
  105.     BEGIN
  106.       x:=x * mx;
  107.       y:=y * my;
  108.     END;
  109.  
  110.   procedure punkt.skalieren(bx,by,vx,vy: real);
  111.  
  112.      BEGIN
  113.       addition(-bx,-by);
  114.       multiply(vx,vy);
  115.       addition(bx,by);
  116.      END;
  117.  
  118.   PROCEDURE punkt.spiegelnY(cy : real);
  119.  
  120.     BEGIN
  121.       addition((-1)*cy,0);
  122.       multiply(-1,1);
  123.       addition(cy,0);
  124.  
  125.     END;
  126.  
  127.   PROCEDURE punkt.spiegelnX(cx : real);
  128.  
  129.     BEGIN
  130.       addition(0,(-1)*cx);
  131.       multiply(1,-1);
  132.       addition(0,cx);
  133.  
  134.     END;
  135.  
  136.  
  137. {-------------------------------Objekt Linie---------------------------------}
  138.  
  139.   CONSTRUCTOR linie.init(xwert,ywert,x1wert,y1wert : REAL);
  140.  
  141.     BEGIN
  142.       x := xwert;
  143.       y := ywert;
  144.       x1 := x1wert;
  145.       y1 := y1wert;
  146.     END;
  147.  
  148.   PROCEDURE linie.out(VAR xwert,ywert,x1wert,y1wert : REAL);
  149.  
  150.     BEGIN
  151.       xwert := x;
  152.       ywert := y;
  153.       x1wert := x1;
  154.       y1wert := y1;
  155.     END;
  156.  
  157.   PROCEDURE linie.zeigen;
  158.  
  159.     BEGIN
  160.       line(round(x),round(y),round(x1),round(y1));
  161.     END;
  162.  
  163.   PROCEDURE linie.addition;
  164.  
  165.     BEGIN
  166.       x := x + dx;
  167.       y := y + dy;
  168.       x1 := x1 + dx;
  169.       y1 := y1 + dy;
  170.     END;
  171.  
  172.   PROCEDURE linie.multiply(mx,my: REAL);
  173.  
  174.      BEGIN
  175.  
  176.      x:=x * mx;
  177.      y:=y * my;
  178.      x1:=x1 * mx;
  179.      y1:=y1 * my;
  180.  
  181.      END;
  182.  
  183.  
  184. {------------------------------Objekt Kreis----------------------------------}
  185.  
  186.   CONSTRUCTOR kreis.init(xwert,ywert,rad : REAL);
  187.  
  188.     BEGIN
  189.       x := xwert;
  190.       y := ywert;
  191.       radius := rad;
  192.     END;
  193.  
  194.   PROCEDURE kreis.out(VAR xwert,ywert,rad : REAL);
  195.  
  196.     BEGIN
  197.       xwert := x;
  198.       ywert := y;
  199.       rad := radius;
  200.     END;
  201.  
  202.   PROCEDURE kreis.zeigen;
  203.  
  204.     BEGIN
  205.       circle(round(x),round(y),round(radius));
  206.     END;
  207.  
  208. {-------------------------------Objekt Rechteck 1----------------------------}
  209.  
  210.   PROCEDURE rechteck.zeigen;
  211.  
  212.     BEGIN
  213.       rectangle(round(x),round(y),round(x1),round(y1));
  214.     END;
  215.  
  216. {--------------------------------Hauptprogramm-------------------------------}
  217.  
  218. { Ab hier stehen alle Verschiebungsprozeduren fr die vordefinierten Objekte }
  219. { zur Verfgung!                                                             }
  220.  
  221.   VAR
  222.     graphdriver,
  223.     graphmode,
  224.     dx,
  225.     realdx,
  226.     realdy,
  227.     zoom,
  228.     circx,
  229.     circy,
  230.     sx1,sy1,cx1,cy1,
  231.     bx,by,
  232.     dy            : INTEGER;
  233.     vx,vy,vx1,vy1 : real;
  234.     ch,ch1        : CHAR;
  235.     opunkt        : punkt;
  236.     olinie        : linie;
  237.     orechteck     : rechteck;
  238.     nrechteck     : rechteck;
  239.     okreis        : kreis;
  240.     ncircle       : kreis;
  241.  
  242.   BEGIN
  243.  
  244.     { Anzeigeobjekte vordefinieren }
  245.     bx:=320;
  246.     by:=240;
  247.     vx:=1.01;
  248.     vy:=1.01;
  249.     vx1:=0.99;
  250.     vy1:=0.99;
  251.     cx1:=240;
  252.     cy1:=320;
  253.     sx1:=1;
  254.     sy1:=-1;
  255.     okreis.init(320,240,50);
  256.     orechteck.init(220,180,420,300);
  257.     opunkt.init(320,240);
  258.     olinie.init(230,190,260,190);
  259.  
  260.     { Eingeben der Dx und Dy Werte }
  261.  
  262.     write('Bitte geben Sie den Y-Skalierwert ein (>1): ');readln(vy);
  263.     write('Bitte geben Sie den X-Skalierwert ein (>1): ');readln(vx);
  264.     write('Bitte geben Sie den Y-Skalierwert ein (0<>1): ');readln(vy1);
  265.     write('Bitte geben Sie den X-Skalierwert ein (0<>1): ');readln(vx1);
  266.  
  267.     { Grafikmodus einschalten }
  268.     graphdriver := detect;
  269.     initgraph(graphdriver,graphmode,'c:\tp\bgi');
  270.  
  271.     { Objekte darstellen }
  272. {    okreis.zeigen;
  273.     orechteck.zeigen;
  274.     olinie.zeigen;
  275.     opunkt.zeigen;
  276.     nrechteck.zeigen;
  277.     ncircle.zeigen; }
  278.  
  279.     { Arbeitsschleife }
  280.     repeat
  281.       cleardevice;
  282.       okreis.zeigen;
  283.       orechteck.zeigen;
  284.       olinie.zeigen;
  285.       opunkt.zeigen;
  286.       ch := readkey;
  287.       case ch of
  288.                   'c' : begin
  289.     settextstyle(1,0,1);
  290.     outtextxy(0,10,'Bitte geben Sie den Y-Skalierwert ein (>1): ');gotoxy(60,2);readln(vy);
  291.     outtextxy(0,30,'Bitte geben Sie den X-Skalierwert ein (>1): ');gotoxy(60,3);readln(vx);
  292.     outtextxy(0,50,'Bitte geben Sie den Y-Skalierwert ein (0<>1): ');gotoxy(60,4);readln(vy1);
  293.     outtextxy(0,70,'Bitte geben Sie den X-Skalierwert ein (0<>1): ');gotoxy(60,5);readln(vx1);
  294.                        cleardevice;
  295.                        end;
  296.  
  297.                   'z' : begin
  298.                          opunkt.skalieren(bx,by,vx,vy);
  299.                          okreis.skalieren(bx,by,vx,vy);
  300.                          orechteck.skalieren(bx,by,vx,vy);
  301.                          olinie.skalieren(bx,by,vx,vy);
  302.                         end;
  303.                   'Z' : begin
  304.                          opunkt.skalieren(bx,by,vx1,vy1);
  305.                          okreis.skalieren(bx,by,vx1,vy1);
  306.                          orechteck.skalieren(bx,by,vx1,vy1);
  307.                          olinie.skalieren(bx,by,vx1,vy1);
  308.                         end;
  309.  
  310.                   'x' : begin
  311.                          olinie.spiegelnX(cx1);
  312.                          opunkt.spiegelnX(cx1);
  313.                          okreis.spiegelnX(cx1);
  314.                          orechteck.spiegelnX(cx1);
  315.                         end;
  316.                   'y' : begin
  317.                          olinie.spiegelnY(cy1);
  318.                          opunkt.spiegelnY(cy1);
  319.                          okreis.spiegelnY(cy1);
  320.                          orechteck.spiegelnY(cy1);
  321.                         end;
  322.                   else write (#7);
  323.  
  324.                 END;
  325.  
  326.    
  327.     UNTIL ch=#13; { abbrechen, wenn RETURN gedrckt wurde }
  328.     closegraph;  { zurckkehren zum Text-Modus }
  329.   END.
  330.